package p8selfSort;

import org.apache.lucene.index.IndexReader;
import org.apache.lucene.search.Query;
import org.apache.lucene.search.function.CustomScoreProvider;
import org.apache.lucene.search.function.CustomScoreQuery;
import org.apache.lucene.search.function.ValueSourceQuery;

import java.io.IOException;

public class MyCustomerScoreQuery extends CustomScoreQuery{

    public MyCustomerScoreQuery(Query subQuery, ValueSourceQuery valSrcQuery) {
        super(subQuery, valSrcQuery);
    }
    protected CustomScoreProvider getCustomScoreProvider(IndexReader reader) throws IOException {
        //默认评分是，通过原有评分*我们传过来的评分字段 所获取的评分，来确定最终评分
        //为了根据不同的需求进行评分，需要自己进行评分设定
        //自定评分的步骤，1 创建一个类继承 CustomScoreProvider
        //2,覆盖 customerScore方法
        //return new CustomScoreProvider(reader);
        //这里面就不能用默认的了，要用自己定义的
        return new MyCustomScoreProvider(reader);
    }

}
